package com.sinsoft.monitorDemo.dao;

import java.util.ArrayList;
import java.util.List;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.sinsoft.monitorDemo.util.FileUtil;

public class TomcatNameDao {
	public List<String> getTomcatName(String ip){
		String tomcatJson = FileUtil.readFile("src/main/java/tomcat.json");
		JsonParser parser = new JsonParser();
		JsonObject object = (JsonObject)parser.parse(tomcatJson);
		JsonArray array = (JsonArray)object.get(ip);
		List<String> tomcats = new ArrayList<String>();
		for (int i = 0; i < array.size(); i++) {
			String tomcatName = array.get(i).getAsString();
			tomcats.add(tomcatName);
		}
		return tomcats;
		
	} 

}
